package cn.iocoder.yudao.module.def.controller.admin.mysql;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.def.controller.admin.mysql.vo.BackupsDO;
import cn.iocoder.yudao.module.def.controller.admin.mysql.vo.BackupsPageReqVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * InterfaceName:SystemMysqlBackupsMapper
 * 接口描述： MySQL备份接口
 */
@Mapper
public interface SystemMysqlBackupsMapper extends BaseMapperX<BackupsDO> {

    /**
     * 查询所有备份数据
     */
    List<BackupsDO> selectBackupsList();

    /**
     * 根据ID查询
     */
    BackupsDO selectListId(@Param("id") Long id);

    default PageResult<BackupsDO> selectPage(BackupsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BackupsDO>()
                .eqIfPresent(BackupsDO::getMysqlIp, reqVO.getMysqlIp())
                .eqIfPresent(BackupsDO::getMysqlPort, reqVO.getMysqlPort())
                .eqIfPresent(BackupsDO::getMysqlCmd, reqVO.getMysqlCmd())
                .eqIfPresent(BackupsDO::getMysqlBackCmd, reqVO.getMysqlBackCmd())
                .likeIfPresent(BackupsDO::getDatabaseName, reqVO.getDatabaseName())
                .eqIfPresent(BackupsDO::getBackupsPath, reqVO.getBackupsPath())
                .likeIfPresent(BackupsDO::getBackupsName, reqVO.getBackupsName())
                .eqIfPresent(BackupsDO::getOperation, reqVO.getOperation())
                .eqIfPresent(BackupsDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BackupsDO::getRecoveryTime, reqVO.getRecoveryTime())
                .betweenIfPresent(BackupsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BackupsDO::getId));
    }

}
